//
//  PhotoBrowserController.swift
//  SinaWeibo
//
//  Created by 胡阳 on 16/6/12.
//  Copyright © 2016年 young4ever. All rights reserved.
//

import UIKit

class PhotoBrowserController: UIViewController {

    var currentIndex : Int?
    var pictureURLs : [NSURL]?
    
    init(index: Int, urls: [NSURL]){
        
        // swift语法中必须先初始化本类的属性 , 然后再初始化父类
        currentIndex = index
        pictureURLs = urls
        super.init(nibName: nil, bundle: nil)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 初始化UI
        setupUI()
    }
    
    private func setupUI()
    {
        view.backgroundColor = UIColor.blackColor()
        
        // 1.添加子控件
        view.addSubview(closeBtn)
        view.addSubview(saveBtn)
        
        // 2.布局子控件
        closeBtn.xmg_AlignInner(type: XMG_AlignType.BottomLeft, referView: view, size: CGSize(width: 100, height: 40), offset: CGPoint(x: 10, y: -10))
        saveBtn.xmg_AlignInner(type: XMG_AlignType.BottomRight, referView: view, size: CGSize(width: 100, height: 40), offset: CGPoint(x: -10, y: -10))
    }
    
    func closeButtonClick(btn: UIButton)
    {
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    func saveButtonClick(btn: UIButton)
    {
        
    }

    //MARK:- 拉加载
    private lazy var closeBtn: UIButton = {
    
        let btn = UIButton()
        btn.setTitle("关闭", forState: .Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        btn.backgroundColor = UIColor.darkGrayColor()
        btn.addTarget(self, action: #selector(PhotoBrowserController.closeButtonClick(_:)), forControlEvents: .TouchUpInside)
        return btn
    }()
    
    private lazy var saveBtn: UIButton = {
        
        let btn = UIButton()
        btn.setTitle("保存", forState: .Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        btn.backgroundColor = UIColor.darkGrayColor()
        btn.addTarget(self, action: #selector(PhotoBrowserController.saveButtonClick(_:)), forControlEvents: .TouchUpInside)
        return btn
    }()
}
